package cn.uexpo.lhz.biz.impl;


import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;



import cn.uexpo.lhz.biz.ActivityMapBiz;
import cn.uexpo.lhz.common.oldBase.BOException;
import cn.uexpo.lhz.common.oldBase.BaseBiz;
import cn.uexpo.lhz.common.oldBase.BaseBizWithBLOBs;
import cn.uexpo.lhz.common.oldUtils.PageRequest;
import cn.uexpo.lhz.common.oldUtils.PageResult;
import cn.uexpo.lhz.common.oldUtils.PageUtils;
import cn.uexpo.lhz.dao.ActivityMapMapper;
import cn.uexpo.lhz.domain.ActivityMap;
import cn.uexpo.lhz.domain.ActivityMapExample;
import cn.uexpo.lhz.domain.ActivityMap;
import cn.uexpo.lhz.domain.ActivityMapExample;
import cn.uexpo.lhz.domain.ManageEquipment;
import cn.uexpo.lhz.domain.ManageEquipmentExample;
@Transactional
@Service
public class ActivityMapBizImpl implements ActivityMapBiz {

	@Autowired
	private ActivityMapMapper activityMapMapper;

	@Override
	public int insert(ActivityMap record) throws BOException {
		return activityMapMapper.insert(record);
	}

	@Override
	public int insertSelective(ActivityMap record) throws BOException {
		return activityMapMapper.insertSelective(record);
	}

	@Override
	public int deleteByPrimaryKey(Integer id) throws BOException {
		return activityMapMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int deleteEntity(ActivityMap record) throws BOException {
		return activityMapMapper.deleteByPrimaryKey(record.getId());
	}

	@Override
	public int deleteByIds(List<Integer> ids) throws BOException {
		int no=0;
		if (null!=ids) {
			for (Integer id : ids) {
				no=activityMapMapper.deleteByPrimaryKey(id);
				if (no==0) {
					throw new RuntimeException("删除失败。") ;
				}
			}
		}

		return no;
	}

	@Override
	public int delete(List<ActivityMap> records) throws BOException {
		int no=0;
		if (null!=records&&records.size()>0){
			for (ActivityMap activityMapEntity : records) {
				no=activityMapMapper.deleteByPrimaryKey(activityMapEntity.getId());
				if (no==0) {
					throw new RuntimeException("删除失败。") ;
				}
			}
		}

		return no;
	}

	@Override
	public int deleteByExample(ActivityMapExample example) throws BOException {
		return activityMapMapper.deleteByExample(example);
	}

	@Override
	public int updateByPrimaryKey(ActivityMap record) throws BOException {
		return activityMapMapper.updateByPrimaryKey(record);
	}

	@Override
	public int updateByPrimaryKeySelective(ActivityMap record) throws BOException {
		return activityMapMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByExampleSelective(ActivityMap record, ActivityMapExample example) throws BOException {
		return activityMapMapper.updateByExampleSelective(record, example);

	}

	@Override
	public int updateByExample(ActivityMap record, ActivityMapExample example) throws BOException {
		return activityMapMapper.updateByExample(record, example);

	}

	@Override
	public ActivityMap selectByPrimaryKey(Integer id) throws BOException {
		return activityMapMapper.selectByPrimaryKey(id);

	}

	@Override
	public ActivityMap selectByUniqueCode(String uniqueCode) throws BOException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<ActivityMap> selectByExample(ActivityMapExample example) throws BOException {
		return activityMapMapper.selectByExample(example);

	}

	@Override
	public long countByExample(ActivityMapExample example) throws BOException {
		return activityMapMapper.countByExample(example);

	}

	@Override
	public PageResult findPage(PageRequest pageRequest, ActivityMapExample example) throws BOException {
		int pageNum = pageRequest.getPage();
	    int pageSize = pageRequest.getLimit();
	    PageHelper.startPage(pageNum, pageSize);
	    List<ActivityMap> records = (List<ActivityMap>) activityMapMapper.selectByExampleWithBLOBs(example);
	    return PageUtils.getPageResult(pageRequest, new PageInfo<ActivityMap>(records));

	}

	@Override
	public List<ActivityMap> selectByExampleWithBLOBs(ActivityMapExample example) throws BOException {
		return activityMapMapper.selectByExampleWithBLOBs(example);
	}

	@Override
	public int updateByExampleWithBLOBs(ActivityMap record, ActivityMapExample example) throws BOException {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int updateByPrimaryKeyWithBLOBs(ActivityMap record) throws BOException {
		return activityMapMapper.updateByPrimaryKeyWithBLOBs(record);
	}


 }
